#include <stdio.h>
#include <stdlib.h>


#define F_PRINT_ERR(e)\
do\
{\
    if(e == NULL)\
    {\
        printf("open error\n");\
        exit(-1);\
    }\
}\
while (0)

int main()
{
    FILE * pf = fopen("a.txt","w+");
    F_PRINT_ERR(pf);

    fputc('a',pf);
    fputc('\n',pf);
    fputc('b',pf);

    rewind(pf);

    int ch;
    ch = fgetc(pf);
    printf("%x",ch);
    ch = fgetc(pf);
    printf("%x",ch);
    ch = fgetc(pf);
    printf("%x",ch);
    ch = fgetc(pf);
    printf("%x",ch);
    fclose(pf);

    return 0;
}
